/**
 * Created with IntelliJ IDEA.
 * User: Nikita.Brazhnikov
 * Date: 3/4/13
 * Time: 1:55 PM
 * To change this template use File | Settings | File Templates.
 */

function checkEmptyLogin(componentId, formname) {
    var formId = componentId + "\\:" + formname;
    var inputs = $('#' + formId + " :input").filter(':text, :password');
    var missedInputs = [];
    $.each(inputs, function() {
       if (!$(this).val()) {
           missedInputs.push(this);
       }
    });
    if (missedInputs.length == 0) {
        return true;
    } else {
        var errStr = "The next required fields are empty:";
        for (var i = 0; i < missedInputs.length; i++) {
            var o = missedInputs[i];
            var label = $("label[for = '" + o.id + "']")
            if (label)
                errStr += (" " + label.text());
            else
                errStr += (" " + o.id);
        }
        alert(errStr);
        return false;
    }
}